﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using uTorrentRemote.TokenSources;
using uTorrentRemote.TokenDispatchers;
using uTorrentRemote.TokenSources.Imap;
using System.Threading;

namespace uTorrentRemote
{
    class Program
    {
        static void Main(string[] args)
        {
            ILog log = new ConsoleLog();

            ITokenSource source = new ImapTokenSource(log);
            List<ITokenDispatcher> dispatchers = new List<ITokenDispatcher>();
            
            dispatchers.Add(new RuTrackerDownloadDispatcher(log));
            dispatchers.Add(new AnimeLayerDownloadDispatcher(log));

            while (true)
            {
                while (source.IsNextTokenAvailable())
                {
                    Token token = source.FetchNextToken();
                    foreach (ITokenDispatcher dispatcher in dispatchers)
                    {
                        if (dispatcher.TryToken(token))
                            break;
                    }
                }
                Thread.Sleep(10 * 1000);
            }
        }
    }
}
